package com.ruoyi.business.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.business.vo.AirPressureGroupVO;
import com.ruoyi.business.vo.BaseWaterVo;
import com.ruoyi.common.annotation.Anonymous;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.RadtubeTempHistory;
import com.ruoyi.business.service.IRadtubeTempHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 辐射管温度历史记录Controller
 * 
 * @author qiancheng
 * @date 2025-10-11
 */
@RestController
@RequestMapping("/business/radtube")
public class RadtubeTempHistoryController extends BaseController
{
    @Autowired
    private IRadtubeTempHistoryService radtubeTempHistoryService;

    /**
     * 查询辐射管温度历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(RadtubeTempHistory radtubeTempHistory)
    {
        startPage();
        List<RadtubeTempHistory> list = radtubeTempHistoryService.selectRadtubeTempHistoryList(radtubeTempHistory);
        return getDataTable(list);
    }

    /**
     * 导出辐射管温度历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:history:export')")
    @Log(title = "辐射管温度历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RadtubeTempHistory radtubeTempHistory)
    {
        List<RadtubeTempHistory> list = radtubeTempHistoryService.selectRadtubeTempHistoryList(radtubeTempHistory);
        ExcelUtil<RadtubeTempHistory> util = new ExcelUtil<RadtubeTempHistory>(RadtubeTempHistory.class);
        util.exportExcel(response, list, "辐射管温度历史记录数据");
    }

    /**
     * 获取辐射管温度历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(radtubeTempHistoryService.selectRadtubeTempHistoryById(id));
    }

    /**
     * 新增辐射管温度历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:history:add')")
    @Log(title = "辐射管温度历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RadtubeTempHistory radtubeTempHistory)
    {
        return toAjax(radtubeTempHistoryService.insertRadtubeTempHistory(radtubeTempHistory));
    }

    /**
     * 修改辐射管温度历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:history:edit')")
    @Log(title = "辐射管温度历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RadtubeTempHistory radtubeTempHistory)
    {
        return toAjax(radtubeTempHistoryService.updateRadtubeTempHistory(radtubeTempHistory));
    }

    /**
     * 删除辐射管温度历史记录
     */
    @PreAuthorize("@ss.hasPermi('business:history:remove')")
    @Log(title = "辐射管温度历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(radtubeTempHistoryService.deleteRadtubeTempHistoryByIds(ids));
    }

    /**
     * 实验平台管理->>立式四级页面->>辐射管温度均匀性测试
     * @return
     */
    @Anonymous
    @GetMapping("/getRadTubeSurfTemps")
    public AjaxResult getRadTubeSurfaceTemps(
                                   @RequestParam("importDay") @DateTimeFormat(pattern = "yyyy-MM-dd") Date importDay,
                                   @RequestParam("startTime") String startTime,
                                   @RequestParam("endTime") String endTime) {
        BaseWaterVo baseWaterVo= radtubeTempHistoryService.getRadTubeSurfTemps(importDay,
                startTime,
                endTime);
        return AjaxResult.success(baseWaterVo);
    }

}
